<?php


namespace App\Controller;


use App\Common\Utils\ResponseUtils;
use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class IndexController extends Controller
{
    private $logger;
    private $jwtManager;

    /**
     * IndexController constructor.
     * @param LoggerInterface $logger
     * @param JWTTokenManagerInterface $jwtManager
     */
    public function __construct(LoggerInterface $logger, JWTTokenManagerInterface $jwtManager)
    {
        $this->logger = $logger;
        $this->jwtManager = $jwtManager;
    }


    /**
     * @Route(path="/", methods={"GET"}, name="index_home")
     */
    public function number()
    {
        $number = [1, 2, 3, 4];

        // get jwt token user info
//        $user = $this->get('security.token_storage')->getToken()->getUser();
        return new JsonResponse($number);
    }

    /**
     * @Route(path="/redis", methods={"GET"}, name="redis_route")
     */
    public function redis() {
        $redis = $this->get("snc_redis.default");
        $redis->set('age',24);

        $age = $redis->get('age');
        return ResponseUtils::success($age);
    }

    /**
     * @Route(path="/test", name="test", methods={"GET"})
     * @return Response
     */
    public function test() {
        return ResponseUtils::success("hello world");
    }
}